package com.lc.jooq.project.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by liangchao03 on 2017/6/30.
 */
public class Test {
    public static void main(String[] args) {
        int[] a1 = new int[30];
        for(int i = 0 ; i < a1.length ; i++){
            a1[i] = 30-i;
        }

        System.out.println(Arrays.toString(a1));
        List<int[]> result = generate();
        for (int i=0;i<result.size();i++){
            System.out.println((i+1) + "号:"+getResult(getMax(a1,result.get(i))));
        }

    }

    public static List<int[]> generate(){
        List<int[]> list = new ArrayList<>(30);
        int start = 0;
        while(start < 30){
            int[] arr = new int[30];
            int right = 30;
            int left = 1;
            for ( int i = start ;i < 30; i++){
                arr[i] = right;
                right--;
            }
            for(int i = start -1;i >=0;i--){
                arr[i] = left;
                left ++;
            }
            list.add(arr);
            start ++;
            System.out.println(Arrays.toString(arr));
        }
        return list;
    }

    public static int[] getMax(int[] a1, int[] a2){
        int[] result = new int[a1.length];
        for (int i=0; i < a1.length; i ++){
            if(a1[i] > a2[i]){
                result[i] = a1[i];
            }else{
                result[i] = a2[i];
            }
        }
        return result;
    }

    public static int getResult(int[] a1){
        int result = 0;
        for (int i=0;i<a1.length; i++){
            result += a1[i];
        }
        return result;
    }
}
